package com.wxx.maker.generator.file;


import freemarker.template.TemplateException;

import java.io.File;
import java.io.IOException;

/**
 * 核心生成器(接收者)
 */
public class FileGenerator {

    /**
     * 生成(实际执行的功能)
     * @param model 数据模型
     */
    public static void doGenerate(Object model) throws IOException, TemplateException {
        String projectPath = System.getProperty("user.dir");//获取项目的根目录
        //输入路径
        String inputPath = projectPath + File.separator + "you-generator-demo-projects" + File.separator + "acm-template";
        //生成静态文件
        StaticFileGenerator.copyFilesByHutool(inputPath, projectPath);

        //生成动态文件
        String dynamicInputPath = projectPath + File.separator + "you-generator-maker" + File.separator + "src/main/resources/templates/MainTemplate.java.ftl";
        String dynamicOutputPath = projectPath + File.separator + "acm-template/src/com/wxx/acm/MainTemplate.java";

        DynamicFileGenerator.doGenerate(dynamicInputPath, dynamicOutputPath, model);
    }


}
